<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>edit</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="__STATIC__/xadmin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/xadmin/css/xadmin.css">
    <script type="text/javascript" src="__STATIC__/xadmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__STATIC__/xadmin/js/xadmin.js"></script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>账号名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" lay-verify="required" class="layui-input" value="{$info.name}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>账号ID</label>
                    <div class="layui-input-inline">
                        <input type="text" name="a_id" lay-verify="required" class="layui-input" value="{$info.a_id}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>优化师</label>
                    <div class="layui-input-inline">
                        <select name="m_id">
                            {volist name="memlist" id="vo"}
                            <option value="{$vo.uid}" {if condition="$vo.uid eq $info.m_id"}selected{/if}>{$vo.username}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>广告商</label>
                    <div class="layui-input-inline">
                        <select name="ader_id">
                            {volist name="adlist" id="vo"}
                            <option value="{$vo.id}" {if condition="$vo.id eq $info.ader_id"}selected{/if}>{$vo.ader}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>代理商</label>
                    <div class="layui-input-inline">
                        <select name="agent_id">
                            {volist name="aglist" id="vo"}
                            <option value="{$vo.id}" {if condition="$vo.id eq $info.agent_id"}selected{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>类型</label>
                    <div class="layui-input-inline">
                        <select name="push_type">
                            <option value="1" {if condition="$info.push_type eq 1"}selected{/if}>搜索</option>
                            <option value="2" {if condition="$info.push_type eq 2"}selected{/if}>信息流</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>返点</label>
                    <div class="layui-input-inline">
                        <input type="text" name="rebate" lay-verify="required" class="layui-input" onkeyup="value=value.replace(/[^\d.]/g,'')" value="{$info.rebate}">
                        <span style="position: absolute;right: -15px;top: 0;bottom: 0;margin: auto; line-height: 30px;">%</span>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>初始余额</label>
                    <div class="layui-input-inline">
                        <input type="text" name="init_money" lay-verify="required" class="layui-input" onkeyup="value=value.replace(/[^\d.]/g,'')" value="{$info.init_money}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>开户日期</label>
                    <div class="layui-input-inline">
                        <input type="text" id="optime" name="open_time" lay-verify="required" class="layui-input" value="{$info.open_time|date='Y-m-d',###}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label"><span class="x-red">*</span>状态</label>
                    <div class="layui-input-inline">
                        <select name="status">
                            <option value="1" {if condition="$info.status eq 1"}selected{/if}>正常</option>
                            <option value="2" {if condition="$info.status eq 2"}selected{/if}>停用</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_repass" class="layui-form-label"></label>
                    <button class="layui-btn" lay-filter="add" lay-submit="">确认</button>
                </div>
            </form>
        </div>
    </div>

<script>

    layui.use(['laydate', 'form'],function() {
        var laydate = layui.laydate;
        $=layui.jquery;
        var form = layui.form
        //执行一个laydate实例
        laydate.render({
            elem: '#optime' //指定元素
        });

        //监听提交
        form.on('submit(add)', function(data){
            $.ajax({
                type: "post",
                url: "{:url('account/edit')}",
                data: {
                    id:{$info.id},
                    name:data.field.name,
                    a_id:data.field.a_id,
                    m_id:data.field.m_id,
                    ader_id:data.field.ader_id,
                    agent_id:data.field.agent_id,
                    push_type:data.field.push_type,
                    rebate:data.field.rebate,
                    init_money:data.field.init_money,
                    open_time:data.field.open_time,
                    status:data.field.status
                },
                success: function(data){
                    if(data.status == 1){
                        layer.msg('修改成功!',{icon:1,time:1000});
                        setTimeout(function(){
                            parent.location.href="{:url('account/index')}";
                        },1000);
                    }else{
                        layer.msg('修改失败!',{icon:2,time:1000});
                    }
                }
            });
            return false;
        });
    });
</script>

</body>
</html>